package com.zxy.supplier_system.server.repository

import com.zxy.supplier_system.server.entity.MarketOrderItem
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository

@Suppress("FunctionName")
interface MarketOrderItemRepository:JpaRepository<MarketOrderItem,Int> {

    fun findAllByMarketOrder_IdOrderBySequenceAsc(marketOrder_id: Int, pageable: Pageable):Page<MarketOrderItem>

    fun existsByMarketOrder_IdAndGoods_Id(marketOrder_id: Int, goods_id: Int):Boolean

    fun findByMarketOrder_IdAndGoods_Id(marketOrder_id: Int, goods_id: Int): MarketOrderItem?

    fun existsByMarketOrder_IdAndGoods_Barcode(marketOrder_id: Int, goods_barcode: String):Boolean;

    fun findFirstByMarketOrder_Market_IdAndGoods_IdOrderByMarketOrder_CreatedDateTimeDesc(market_id: Int, goods_id: Int):MarketOrderItem?

    fun findFirstByMarketOrder_Market_IdAndGoods_IdAndSubGoods_IdOrderByMarketOrder_CreatedDateTimeDesc(market_id: Int, goods_id: Int,subGoods_id: Int):MarketOrderItem?

    fun findByMarketOrder_IdAndGoods_IdAndSubGoods_Id(marketOrder_id: Int, goods_id: Int, subGoods_id: Int?): MarketOrderItem?

}
